/*
 * Copyright (C) 2013 47 Degrees, LLC
 *  http://47deg.com
 *  hello@47deg.com
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package com.habbot.beautifyinghandbook.adapters;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;

import com.habbot.beautifyinghandbook.R;
import com.habbot.beautifyinghandbook.objects.ItemObject;

import java.util.List;

public class FavouriteAdapter extends ArrayAdapter<ItemObject> {

	public FavouriteAdapter(Context context, List<ItemObject> data) {
		super(context, R.layout.item_layout, data);
	}


	@Override
	public View getView(final int position, View convertView, final ViewGroup parent) {
		final ItemObject item = getItem(position);
		final ViewHolder holder;
		if (convertView == null) {
			Log.d("CONVERT_VIEW", position+"-null");
			LayoutInflater li = (LayoutInflater) getContext()
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = li.inflate(R.layout.item_layout, parent, false);
			holder = new ViewHolder();
			holder.imgItemIcon = (ImageView) convertView
					.findViewById(R.id.img_item_icon);
			holder.tvTitle = (TextView) convertView.findViewById(R.id.tv_title);
			convertView.setTag(holder);
		} else {
			Log.d("CONVERT_VIEW", position+"");
			holder = (ViewHolder) convertView.getTag();
		}
		
		holder.tvTitle.setText(item.getTitle());


		return convertView;
	}

	public class ViewHolder {
		public ImageView imgItemIcon;
		public TextView tvTitle;
	}

}
